package com.example.activity.listener;

import com.example.activity.dao.GeaUserDao;
import com.example.activity.dao.TaskApproverDao;
import com.example.activity.pojo.GeaUser;
import com.example.activity.pojo.TaskApprover;
import com.example.activity.utils.SpringUtil;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;

/**
 * @author Create by Ron
 * @date 2020/5/18 0:23
 */
public class TaskApproverListener implements TaskListener {


    @Override
    public void notify(DelegateTask delegateTask) {

        TaskApproverDao taskApproverDao = SpringUtil.getObject(TaskApproverDao.class);
        GeaUserDao geaUserDao = SpringUtil.getObject(GeaUserDao.class);

        System.out.println("任务ID：" + delegateTask.getTaskDefinitionKey());

       TaskApprover taskApprover  = taskApproverDao.findByTaskId(delegateTask.getTaskDefinitionKey());

        GeaUser geauser = geaUserDao.findById(taskApprover.getGeaUserId()).orElse(null);

        delegateTask.setAssignee(geauser.getName());

    }


}
